-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[JEWEL-992] Hide mouse cursor while typing in BTF on macOS #3372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[JEWEL-992] Hide mouse cursor while typing in BTF on macOS #3372
Conversation
faogustavo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blockers :)
3c1838d to
8f771d3
Compare
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePlatformCursorController.kt
Show resolved
Hide resolved
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/HideCursorOnTyping.kt
Outdated
Show resolved
Hide resolved
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/platform/PlatformCursorController.kt
Show resolved
Hide resolved
8f771d3 to
e3fc7bf
Compare
e3fc7bf to
cd4537d
Compare
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePlatformCursorController.kt
Show resolved
Hide resolved
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePlatformCursorController.kt
Show resolved
Hide resolved
rock3r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Couple minor notes
...e/src/main/kotlin/org/jetbrains/jewel/intui/standalone/StandalonePlatformCursorController.kt
Show resolved
Hide resolved
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/component/HideCursorOnTyping.kt
Outdated
Show resolved
Hide resolved
platform/jewel/ui/src/main/kotlin/org/jetbrains/jewel/ui/platform/PlatformCursorController.kt
Outdated
Show resolved
Hide resolved
cd4537d to
f5f2c94
Compare
rock3r
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
f5f2c94 to
fbc46c1
Compare
| */ | ||
| public interface PlatformCursorController { | ||
| /** Hides the mouse cursor while the user is typing. This is a MacOS-only behavior. */ | ||
| public fun hideCursorWhileTyping() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name hideCursorWhileTyping() doesn't really match what it actually does. Looking at the implementation, it hides the cursor until the next mouse movement on macOS, and does nothing on Windows/Linux.
The name suggests the cursor is hidden while you're actively typing, but it actually stays hidden until you move the mouse - even if you stop typing. Also, the platform-specific behavior isn't obvious from just looking at the function name.
A couple of options to fix this:
- Rename it to something like
hideCursorUntilMouseMoves()orhideCursorWhileIdle()to better describe what's actually happening - Or restructure the
PlatformCursorControllerto actually handle typing events internally and decide when to hide/show the cursor, making it work more like the name suggests
Either way, could you add some documentation about the Windows/Linux behavior? Right now it's not clear that it's a no-op on those platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree with solution 2, let's keep component-specific behaviour in the component itself. We may have other uses for hiding the cursor in the future, we shouldn't leak the specific use case in the composition local.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nebojsa-vuksic I'm not sure if the renaming suggestions are also helpful to explicitly describe what this function does. Maybe just keep it as hideCursor() as it is in the legacy code, and add a little bit more of documentation explaining what it does and when the cursor should be displayed again.
Something like:
/**
* Hides the mouse cursor while the user is typing. The cursor stays hidden until the next mouse movement.
*
* This is a macOS-only behavior. The cursor remains visible on Windows and Linux.
*/
public fun hideCursor()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also drop Hides the mouse cursor while the user is typing. part since it has nothing to do with mouse visibility in this context. Mouse visibility is only affected by it's movement, as your next sentence states. :) In this case, with a proper kdoc, I'm fine with hideCursor function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nebojsa-vuksic @rock3r done. Please review again once you have a chance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the comment about a design of PlatformCursorController.
fbc46c1 to
eeaad22
Compare
eeaad22 to
b646396
Compare
|
Ready to merge |
b646396 to
cb93c96
Compare
Summary
Implements cursor hiding behavior on macOS when typing in text fields, matching the native IDE behavior. The cursor automatically hides when the user types and reappears when the mouse moves.
Evidence
Screen.Recording.2026-01-06.at.6.37.57.PM.mov
Implementation Details
Architecture
Added a platform-specific cursor controller abstraction using Compose composition locals:
PlatformCursorController- Interface for platform-specific cursor controlStandalonePlatformCursorController- macOS implementation using JNA to call[NSCursor setHiddenUntilMouseMoves:YES]BridgePlatformCursorController- Bridge implementation usingMacUIUtil.hideCursor()NoOpPlatformCursorController- Fallback for unsupported platformsIntegration
InputFieldcomponents via.hideCursorOnTyping()modifierLocalPlatformCursorControllercomposition local:IntUiTheme→StandalonePlatformCursorControllerSwingBridgeTheme→BridgePlatformCursorControllerRelease notes
New features
Note
Implements macOS cursor-hiding behavior and abstracts platform-specific control.
PlatformCursorControllerandLocalPlatformCursorControllercomposition localBridgePlatformCursorController(usesMacUIUtil.hideCursor()),StandalonePlatformCursorController(uses JNA to call[NSCursor setHiddenUntilMouseMoves:])SwingBridgeTheme→BridgePlatformCursorController,IntUiTheme→StandalonePlatformCursorControllerInputFieldvia.hideCursorOnTyping()(key preview on keydown; active only when enabled and not read-only)Written by Cursor Bugbot for commit fbc46c1. This will update automatically on new commits. Configure here.